/*******************************************************************************
*                                    ZLG
*                         ----------------------------
*                         innovating embedded platform
*
* Copyright (c) 2001-2021 Guangzhou ZHIYUAN Electronics Co., Ltd.
* All rights reserved.
*
* Contact information:
* web site:    https://www.zlg.cn
*******************************************************************************/
#ifndef __HC34F4A0_REGS_GPIO_H
#define __HC34F4A0_REGS_GPIO_H

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus*/
#include <stdio.h>

/* \brief HC32F4A0 GPIO 端口数量*/
#define GPIO_PORT_MAX  9

/* \brief HC32F4A0 GPIO 引脚功能*/
#define GPIO_FUNC_18                (0x12U)    /* HC32F4A0 GPIO 引脚功能 18 */
#define GPIO_FUNC_20                (0x14U)    /* HC32F4A0 GPIO 引脚功能 20 */
#define GPIO_FUNC_32                (0x20U)    /* HC32F4A0 GPIO 引脚功能 32 */
#define GPIO_FUNC_33                (0x21U)    /* HC32F4A0 GPIO 引脚功能 33 */
#define GPIO_FUNC_34                (0x22U)    /* HC32F4A0 GPIO 引脚功能 34 */
#define GPIO_FUNC_35                (0x23U)    /* HC32F4A0 GPIO 引脚功能 35 */
#define GPIO_FUNC_36                (0x24U)    /* HC32F4A0 GPIO 引脚功能 36 */
#define GPIO_FUNC_37                (0x25U)    /* HC32F4A0 GPIO 引脚功能 37 */
#define GPIO_FUNC_38                (0x26U)    /* HC32F4A0 GPIO 引脚功能 38 */
#define GPIO_FUNC_39                (0x27U)    /* HC32F4A0 GPIO 引脚功能 39 */
#define GPIO_FUNC_63                (0x3FU)    /* HC32F4A0 GPIO 引脚功能 63 */

/* \brief HC32F4A0 GPIO PFSR 功能选择寄存器位定义 */
#define GPIO_PFSR_FSEL_POS          (0U)
#define GPIO_PFSR_FSEL              (0x003FU)
#define GPIO_PFSR_BFE_POS           (8U)
#define GPIO_PFSR_BFE               (0x0100U)

/* \brief HC32F4A0 GPIO PWPR 写保护寄存器位定义 */
#define GPIO_PWPR_WE_POS            (0U)
#define GPIO_PWPR_WE                (0x0001U)
#define GPIO_PWPR_WP_POS            (8U)
#define GPIO_PWPR_WP                (0xFF00U)

/* \brief HC32F4A0 GPIO PCCR 公共控制寄存器位定义  */
#define GPIO_PCCR_BFSEL_POS         (0U)
#define GPIO_PCCR_BFSEL             (0x003FU)
#define GPIO_PCCR_RDWT_POS          (12U)
#define GPIO_PCCR_RDWT              (0x7000U)

/* \brief GPIO PCR 通用控制寄存器位定义  */
#define GPIO_PCR_POUT_POS           (0U)
#define GPIO_PCR_POUT               (0x0001U)
#define GPIO_PCR_POUTE_POS          (1U)
#define GPIO_PCR_POUTE              (0x0002U)
#define GPIO_PCR_NOD_POS            (2U)
#define GPIO_PCR_NOD                (0x0004U)
#define GPIO_PCR_DRV_POS            (4U)
#define GPIO_PCR_DRV                (0x0030U)
#define GPIO_PCR_DRV_0              (0x0010U)
#define GPIO_PCR_DRV_1              (0x0020U)
#define GPIO_PCR_PUU_POS            (6U)
#define GPIO_PCR_PUU                (0x0040U)
#define GPIO_PCR_PIN_POS            (8U)
#define GPIO_PCR_PIN                (0x0100U)
#define GPIO_PCR_INVE_POS           (9U)
#define GPIO_PCR_INVE               (0x0200U)
#define GPIO_PCR_CINSEL_POS         (10U)
#define GPIO_PCR_CINSEL             (0x0400U)
#define GPIO_PCR_INTE_POS           (12U)
#define GPIO_PCR_INTE               (0x1000U)
#define GPIO_PCR_LTE_POS            (14U)
#define GPIO_PCR_LTE                (0x4000U)
#define GPIO_PCR_DDIS_POS           (15U)
#define GPIO_PCR_DDIS               (0x8000U)

/* \brief GPIO 引脚读等待周期选择*/
#define GPIO_READ_WAIT_0            ((uint16_t)(0x00UL << GPIO_PCCR_RDWT_POS))
#define GPIO_READ_WAIT_1            ((uint16_t)(0x01UL << GPIO_PCCR_RDWT_POS))
#define GPIO_READ_WAIT_2            ((uint16_t)(0x02UL << GPIO_PCCR_RDWT_POS))
#define GPIO_READ_WAIT_3            ((uint16_t)(0x03UL << GPIO_PCCR_RDWT_POS))
#define GPIO_READ_WAIT_4            ((uint16_t)(0x04UL << GPIO_PCCR_RDWT_POS))
#define GPIO_READ_WAIT_5            ((uint16_t)(0x05UL << GPIO_PCCR_RDWT_POS))
#define GPIO_READ_WAIT_6            ((uint16_t)(0x06UL << GPIO_PCCR_RDWT_POS))
#define GPIO_READ_WAIT_7            ((uint16_t)(0x07UL << GPIO_PCCR_RDWT_POS))

/* \brief HC32F4A0 GPIO寄存器定义*/
typedef struct {
    volatile uint16_t PIDRA;
    uint8_t           RESERVED0[2];
    volatile uint16_t PODRA;
    volatile uint16_t POERA;
    volatile uint16_t POSRA;
    volatile uint16_t PORRA;
    volatile uint16_t POTRA;
    uint8_t           RESERVED1[2];
    volatile uint16_t PIDRB;
    uint8_t           RESERVED2[2];
    volatile uint16_t PODRB;
    volatile uint16_t POERB;
    volatile uint16_t POSRB;
    volatile uint16_t PORRB;
    volatile uint16_t POTRB;
    uint8_t           RESERVED3[2];
    volatile uint16_t PIDRC;
    uint8_t           RESERVED4[2];
    volatile uint16_t PODRC;
    volatile uint16_t POERC;
    volatile uint16_t POSRC;
    volatile uint16_t PORRC;
    volatile uint16_t POTRC;
    uint8_t           RESERVED5[2];
    volatile uint16_t PIDRD;
    uint8_t           RESERVED6[2];
    volatile uint16_t PODRD;
    volatile uint16_t POERD;
    volatile uint16_t POSRD;
    volatile uint16_t PORRD;
    volatile uint16_t POTRD;
    uint8_t           RESERVED7[2];
    volatile uint16_t PIDRE;
    uint8_t           RESERVED8[2];
    volatile uint16_t PODRE;
    volatile uint16_t POERE;
    volatile uint16_t POSRE;
    volatile uint16_t PORRE;
    volatile uint16_t POTRE;
    uint8_t           RESERVED9[2];
    volatile uint16_t PIDRF;
    uint8_t           RESERVED10[2];
    volatile uint16_t PODRF;
    volatile uint16_t POERF;
    volatile uint16_t POSRF;
    volatile uint16_t PORRF;
    volatile uint16_t POTRF;
    uint8_t           RESERVED11[2];
    volatile uint16_t PIDRG;
    uint8_t           RESERVED12[2];
    volatile uint16_t PODRG;
    volatile uint16_t POERG;
    volatile uint16_t POSRG;
    volatile uint16_t PORRG;
    volatile uint16_t POTRG;
    uint8_t           RESERVED13[2];
    volatile uint16_t PIDRH;
    uint8_t           RESERVED14[2];
    volatile uint16_t PODRH;
    volatile uint16_t POERH;
    volatile uint16_t POSRH;
    volatile uint16_t PORRH;
    volatile uint16_t POTRH;
    uint8_t           RESERVED15[2];
    volatile uint16_t PIDRI;
    uint8_t           RESERVED16[2];
    volatile uint16_t PODRI;
    volatile uint16_t POERI;
    volatile uint16_t POSRI;
    volatile uint16_t PORRI;
    volatile uint16_t POTRI;
    uint8_t           RESERVED17[870];
    volatile uint16_t PSPCR;
    uint8_t           RESERVED18[2];
    volatile uint16_t PCCR;
    volatile uint16_t PINAER;
    volatile uint16_t PWPR;
    uint8_t           RESERVED19[2];
    volatile uint16_t PCRA0;
    volatile uint16_t PFSRA0;
    volatile uint16_t PCRA1;
    volatile uint16_t PFSRA1;
    volatile uint16_t PCRA2;
    volatile uint16_t PFSRA2;
    volatile uint16_t PCRA3;
    volatile uint16_t PFSRA3;
    volatile uint16_t PCRA4;
    volatile uint16_t PFSRA4;
    volatile uint16_t PCRA5;
    volatile uint16_t PFSRA5;
    volatile uint16_t PCRA6;
    volatile uint16_t PFSRA6;
    volatile uint16_t PCRA7;
    volatile uint16_t PFSRA7;
    volatile uint16_t PCRA8;
    volatile uint16_t PFSRA8;
    volatile uint16_t PCRA9;
    volatile uint16_t PFSRA9;
    volatile uint16_t PCRA10;
    volatile uint16_t PFSRA10;
    volatile uint16_t PCRA11;
    volatile uint16_t PFSRA11;
    volatile uint16_t PCRA12;
    volatile uint16_t PFSRA12;
    volatile uint16_t PCRA13;
    volatile uint16_t PFSRA13;
    volatile uint16_t PCRA14;
    volatile uint16_t PFSRA14;
    volatile uint16_t PCRA15;
    volatile uint16_t PFSRA15;
    volatile uint16_t PCRB0;
    volatile uint16_t PFSRB0;
    volatile uint16_t PCRB1;
    volatile uint16_t PFSRB1;
    volatile uint16_t PCRB2;
    volatile uint16_t PFSRB2;
    volatile uint16_t PCRB3;
    volatile uint16_t PFSRB3;
    volatile uint16_t PCRB4;
    volatile uint16_t PFSRB4;
    volatile uint16_t PCRB5;
    volatile uint16_t PFSRB5;
    volatile uint16_t PCRB6;
    volatile uint16_t PFSRB6;
    volatile uint16_t PCRB7;
    volatile uint16_t PFSRB7;
    volatile uint16_t PCRB8;
    volatile uint16_t PFSRB8;
    volatile uint16_t PCRB9;
    volatile uint16_t PFSRB9;
    volatile uint16_t PCRB10;
    volatile uint16_t PFSRB10;
    volatile uint16_t PCRB11;
    volatile uint16_t PFSRB11;
    volatile uint16_t PCRB12;
    volatile uint16_t PFSRB12;
    volatile uint16_t PCRB13;
    volatile uint16_t PFSRB13;
    volatile uint16_t PCRB14;
    volatile uint16_t PFSRB14;
    volatile uint16_t PCRB15;
    volatile uint16_t PFSRB15;
    volatile uint16_t PCRC0;
    volatile uint16_t PFSRC0;
    volatile uint16_t PCRC1;
    volatile uint16_t PFSRC1;
    volatile uint16_t PCRC2;
    volatile uint16_t PFSRC2;
    volatile uint16_t PCRC3;
    volatile uint16_t PFSRC3;
    volatile uint16_t PCRC4;
    volatile uint16_t PFSRC4;
    volatile uint16_t PCRC5;
    volatile uint16_t PFSRC5;
    volatile uint16_t PCRC6;
    volatile uint16_t PFSRC6;
    volatile uint16_t PCRC7;
    volatile uint16_t PFSRC7;
    volatile uint16_t PCRC8;
    volatile uint16_t PFSRC8;
    volatile uint16_t PCRC9;
    volatile uint16_t PFSRC9;
    volatile uint16_t PCRC10;
    volatile uint16_t PFSRC10;
    volatile uint16_t PCRC11;
    volatile uint16_t PFSRC11;
    volatile uint16_t PCRC12;
    volatile uint16_t PFSRC12;
    volatile uint16_t PCRC13;
    volatile uint16_t PFSRC13;
    volatile uint16_t PCRC14;
    volatile uint16_t PFSRC14;
    volatile uint16_t PCRC15;
    volatile uint16_t PFSRC15;
    volatile uint16_t PCRD0;
    volatile uint16_t PFSRD0;
    volatile uint16_t PCRD1;
    volatile uint16_t PFSRD1;
    volatile uint16_t PCRD2;
    volatile uint16_t PFSRD2;
    volatile uint16_t PCRD3;
    volatile uint16_t PFSRD3;
    volatile uint16_t PCRD4;
    volatile uint16_t PFSRD4;
    volatile uint16_t PCRD5;
    volatile uint16_t PFSRD5;
    volatile uint16_t PCRD6;
    volatile uint16_t PFSRD6;
    volatile uint16_t PCRD7;
    volatile uint16_t PFSRD7;
    volatile uint16_t PCRD8;
    volatile uint16_t PFSRD8;
    volatile uint16_t PCRD9;
    volatile uint16_t PFSRD9;
    volatile uint16_t PCRD10;
    volatile uint16_t PFSRD10;
    volatile uint16_t PCRD11;
    volatile uint16_t PFSRD11;
    volatile uint16_t PCRD12;
    volatile uint16_t PFSRD12;
    volatile uint16_t PCRD13;
    volatile uint16_t PFSRD13;
    volatile uint16_t PCRD14;
    volatile uint16_t PFSRD14;
    volatile uint16_t PCRD15;
    volatile uint16_t PFSRD15;
    volatile uint16_t PCRE0;
    volatile uint16_t PFSRE0;
    volatile uint16_t PCRE1;
    volatile uint16_t PFSRE1;
    volatile uint16_t PCRE2;
    volatile uint16_t PFSRE2;
    volatile uint16_t PCRE3;
    volatile uint16_t PFSRE3;
    volatile uint16_t PCRE4;
    volatile uint16_t PFSRE4;
    volatile uint16_t PCRE5;
    volatile uint16_t PFSRE5;
    volatile uint16_t PCRE6;
    volatile uint16_t PFSRE6;
    volatile uint16_t PCRE7;
    volatile uint16_t PFSRE7;
    volatile uint16_t PCRE8;
    volatile uint16_t PFSRE8;
    volatile uint16_t PCRE9;
    volatile uint16_t PFSRE9;
    volatile uint16_t PCRE10;
    volatile uint16_t PFSRE10;
    volatile uint16_t PCRE11;
    volatile uint16_t PFSRE11;
    volatile uint16_t PCRE12;
    volatile uint16_t PFSRE12;
    volatile uint16_t PCRE13;
    volatile uint16_t PFSRE13;
    volatile uint16_t PCRE14;
    volatile uint16_t PFSRE14;
    volatile uint16_t PCRE15;
    volatile uint16_t PFSRE15;
    volatile uint16_t PCRF0;
    volatile uint16_t PFSRF0;
    volatile uint16_t PCRF1;
    volatile uint16_t PFSRF1;
    volatile uint16_t PCRF2;
    volatile uint16_t PFSRF2;
    volatile uint16_t PCRF3;
    volatile uint16_t PFSRF3;
    volatile uint16_t PCRF4;
    volatile uint16_t PFSRF4;
    volatile uint16_t PCRF5;
    volatile uint16_t PFSRF5;
    volatile uint16_t PCRF6;
    volatile uint16_t PFSRF6;
    volatile uint16_t PCRF7;
    volatile uint16_t PFSRF7;
    volatile uint16_t PCRF8;
    volatile uint16_t PFSRF8;
    volatile uint16_t PCRF9;
    volatile uint16_t PFSRF9;
    volatile uint16_t PCRF10;
    volatile uint16_t PFSRF10;
    volatile uint16_t PCRF11;
    volatile uint16_t PFSRF11;
    volatile uint16_t PCRF12;
    volatile uint16_t PFSRF12;
    volatile uint16_t PCRF13;
    volatile uint16_t PFSRF13;
    volatile uint16_t PCRF14;
    volatile uint16_t PFSRF14;
    volatile uint16_t PCRF15;
    volatile uint16_t PFSRF15;
    volatile uint16_t PCRG0;
    volatile uint16_t PFSRG0;
    volatile uint16_t PCRG1;
    volatile uint16_t PFSRG1;
    volatile uint16_t PCRG2;
    volatile uint16_t PFSRG2;
    volatile uint16_t PCRG3;
    volatile uint16_t PFSRG3;
    volatile uint16_t PCRG4;
    volatile uint16_t PFSRG4;
    volatile uint16_t PCRG5;
    volatile uint16_t PFSRG5;
    volatile uint16_t PCRG6;
    volatile uint16_t PFSRG6;
    volatile uint16_t PCRG7;
    volatile uint16_t PFSRG7;
    volatile uint16_t PCRG8;
    volatile uint16_t PFSRG8;
    volatile uint16_t PCRG9;
    volatile uint16_t PFSRG9;
    volatile uint16_t PCRG10;
    volatile uint16_t PFSRG10;
    volatile uint16_t PCRG11;
    volatile uint16_t PFSRG11;
    volatile uint16_t PCRG12;
    volatile uint16_t PFSRG12;
    volatile uint16_t PCRG13;
    volatile uint16_t PFSRG13;
    volatile uint16_t PCRG14;
    volatile uint16_t PFSRG14;
    volatile uint16_t PCRG15;
    volatile uint16_t PFSRG15;
    volatile uint16_t PCRH0;
    volatile uint16_t PFSRH0;
    volatile uint16_t PCRH1;
    volatile uint16_t PFSRH1;
    volatile uint16_t PCRH2;
    volatile uint16_t PFSRH2;
    volatile uint16_t PCRH3;
    volatile uint16_t PFSRH3;
    volatile uint16_t PCRH4;
    volatile uint16_t PFSRH4;
    volatile uint16_t PCRH5;
    volatile uint16_t PFSRH5;
    volatile uint16_t PCRH6;
    volatile uint16_t PFSRH6;
    volatile uint16_t PCRH7;
    volatile uint16_t PFSRH7;
    volatile uint16_t PCRH8;
    volatile uint16_t PFSRH8;
    volatile uint16_t PCRH9;
    volatile uint16_t PFSRH9;
    volatile uint16_t PCRH10;
    volatile uint16_t PFSRH10;
    volatile uint16_t PCRH11;
    volatile uint16_t PFSRH11;
    volatile uint16_t PCRH12;
    volatile uint16_t PFSRH12;
    volatile uint16_t PCRH13;
    volatile uint16_t PFSRH13;
    volatile uint16_t PCRH14;
    volatile uint16_t PFSRH14;
    volatile uint16_t PCRH15;
    volatile uint16_t PFSRH15;
    volatile uint16_t PCRI0;
    volatile uint16_t PFSRI0;
    volatile uint16_t PCRI1;
    volatile uint16_t PFSRI1;
    volatile uint16_t PCRI2;
    volatile uint16_t PFSRI2;
    volatile uint16_t PCRI3;
    volatile uint16_t PFSRI3;
    volatile uint16_t PCRI4;
    volatile uint16_t PFSRI4;
    volatile uint16_t PCRI5;
    volatile uint16_t PFSRI5;
    volatile uint16_t PCRI6;
    volatile uint16_t PFSRI6;
    volatile uint16_t PCRI7;
    volatile uint16_t PFSRI7;
    volatile uint16_t PCRI8;
    volatile uint16_t PFSRI8;
    volatile uint16_t PCRI9;
    volatile uint16_t PFSRI9;
    volatile uint16_t PCRI10;
    volatile uint16_t PFSRI10;
    volatile uint16_t PCRI11;
    volatile uint16_t PFSRI11;
    volatile uint16_t PCRI12;
    volatile uint16_t PFSRI12;
    volatile uint16_t PCRI13;
    volatile uint16_t PFSRI13;
} hc32f4a0_gpio_regs_t;

#define HC32F4A0_GPIO   ((hc32f4a0_gpio_regs_t *)HC32F4A0_GPIO_BASE)

#ifdef __cplusplus
}
#endif  /* __cplusplus  */

#endif

